#pragma once
#include <cstdlib>
#include <cassert>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define LAJITONG "/dev/null"

void daemon(){
    signal(SIGPIPE,SIG_IGN);
    if(fork() != 0)    exit(0);
    int r = setsid();
    //void*(r);
    assert(r != -1);
    int fd = open(LAJITONG,O_RDWR);
    if(fd != -1){
        dup2(fd,0);
        dup2(fd,1);
        dup2(fd,2);
        close(fd);
    }else{
        close(0);
        close(1);
        close(2);
    }
}